package com.yx.shiro;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * shiro加密（MD5）
 */
public class ShiroMD5 {
    public static void main(String[] args) {
        //明文密码
        String password = "123456";
        //使用MD5加密
        Md5Hash md5Hash = new Md5Hash(password);
        System.out.println("md5加密后 = "+md5Hash.toHex());
        //带盐加密
        Md5Hash md5Hash1 = new Md5Hash(password, "2681196279");
        System.out.println("md5带盐加密后 = "+md5Hash1.toHex());
        // 迭代3次加盐 多加几次盐
        Md5Hash md5Hash2 = new Md5Hash(password, "2681196279",3);
        System.out.println("MD5带盐的3次加密"+md5Hash2.toHex());
        //使用父类进行加密
        SimpleHash simpleHash = new SimpleHash("MD5", password,
                "2681196279", 3);
        System.out.println("父类的带盐的三次加密"+simpleHash.toHex());
    }
}
